import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";
import AutoImport from 'unplugin-auto-import/vite'
import Components from 'unplugin-vue-components/vite'
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'
// 引入@vitejs/plugin-legacy
// import legacy from '@vitejs/plugin-legacy';

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [
    vue(),
    //自动按需引入element
    AutoImport({
      resolvers: [ElementPlusResolver()],
    }),
    Components({
      resolvers: [ElementPlusResolver()],
    }),
    // legacy({
    //   targets: ['defaults', 'not IE 11']
    // }),
  ],
  // base:"./",
  //设置反向代理，跨域
  server: {
    host: true,//设置地址：http://localhost
    port: 81, // 设置服务启动端口号
    
    open: true, // 设置服务启动时是否自动打开浏览器
    // cors: true, // 允许跨域
    proxy: {
      '/dev-api': {
        target: 'https://weixin.citicsinfo.com/reqxml?action=1230',//代理的地址
        // target:'http://localhost:8000',
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/dev-api/, '')//这里的/需要转义
      },
     
    }
  },

});


///
